package com.maxima.maximaAttendance.pojos;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name="\"user\"")
@NamedQuery(name="User.findAll", query="SELECT u FROM User u")
public class User implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(unique=true, nullable=false)
	private Integer id;

	@Column(length=50)
	private String firstName;

	@Column(length=100)
	private String lastName;
	
	@Column(length=50)
	private String password;

	@Column
	private Integer employeeId;

	@Column
	private Boolean active;
	
	
	//bi-directional many-to-one association to TimeLog
	@OneToMany(mappedBy="user")
	private List<TimeLog> timeLogs;

	// bi-directional many-to-one association to Project
	@ManyToOne
	@JoinColumn(name = "projectId")
	private Project project;
		
	public User() {
		this.active=true;
	}
	public User(String firstName, String lastName,Integer emp_id, String password) {
		super();
		this.firstName = firstName;
		this.lastName= lastName;
		this.employeeId= emp_id;
		this.password = password;
		this.active=true;
	}
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public Integer getEmployeeId() {
		return employeeId;
	}
	public void setEmployeeId(Integer employeeId) {
		this.employeeId = employeeId;
	}
	
	public Boolean getActive() {
		return active;
	}
	public void setActive(Boolean active) {
		this.active = active;
	}
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	public Project getProject() {
		return project;
	}
	public void setProject(Project project) {
		this.project = project;
	}
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<TimeLog> getTimeLogs() {
		return this.timeLogs;
	}

	public void setTimeLogs(List<TimeLog> timeLogs) {
		this.timeLogs = timeLogs;
	}

	public TimeLog addTimeLog(TimeLog timeLog) {
		getTimeLogs().add(timeLog);
		timeLog.setUser(this);

		return timeLog;
	}

	public TimeLog removeTimeLog(TimeLog timeLog) {
		getTimeLogs().remove(timeLog);
		timeLog.setUser(null);

		return timeLog;
	}

}